<?php
/**
* @file $Id: Comments.inc.php 161 2006-09-07 06:21:17Z doritojones $
* @package Focus/SIS
* @copyright Copyright (C) 2006 Andrew Schmadeke. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* Focus/SIS is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.txt for copyright notices and details.
*/

$_FOCUS['allow_edit'] = true;
if($_REQUEST['modfunc']=='update')
{
	$existing_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM STUDENT_MP_COMMENTS WHERE STUDENT_ID='".UserStudentID()."' AND SYEAR='".UserSyear()."' AND MARKING_PERIOD_ID='".GetParentMP('SEM',UserMP())."'"));
	if(!$existing_RET)
		DBQuery("INSERT INTO STUDENT_MP_COMMENTS (SYEAR,STUDENT_ID,MARKING_PERIOD_ID) values('".UserSyear()."','".UserStudentID()."','".GetParentMP('SEM',UserMP())."')");
	SaveData(array('STUDENT_MP_COMMENTS'=>"STUDENT_ID='".UserStudentID()."' AND SYEAR='".UserSyear()."' AND MARKING_PERIOD_ID='".GetParentMP('SEM',UserMP())."'"),'',array('COMMENT'=>_('Comment')));
	unset($_SESSION['_REQUEST_vars']['modfunc']);
	unset($_SESSION['_REQUEST_vars']['values']);
}

$comments_RET = DBGet(DBQuery("SELECT COMMENT FROM STUDENT_MP_COMMENTS WHERE STUDENT_ID='".UserStudentID()."' AND SYEAR='".UserSyear()."' AND MARKING_PERIOD_ID='".GetParentMP('SEM',UserMP())."'"));
echo '<TABLE>';
echo '<TR>';
echo '<TD valign=bottom>';
echo '<b>'.$mp['TITLE'].' '._('Comments').'</b><BR>';
echo '<TEXTAREA id=textarea name=values[STUDENT_MP_COMMENTS]['.UserStudentID().'][COMMENT] cols=66 rows=22 onkeypress="document.getElementById(\'chars_left\').innerHTML=(1121-this.value.length); if(this.value.length>1121) {document.getElementById(\'chars_left\').innerHTML=\''._('Fewer than 0').'\'}">';
echo $comments_RET[1]['COMMENT'];
echo '</TEXTAREA>';
echo '<table><tr><td><IMG SRC=assets/comment_button.gif onload="document.getElementById(\'chars_left\').innerHTML=1121-document.getElementById(\'textarea\').value.length";></td><td><small><div id=chars_left>1121</div></small></td><td><small>'._('characters remaining.').'<small></td></tr></table>';
echo '</TD>';
echo '<TR><TD align=center><INPUT type=submit value='._('Save').'></TD></TR>';
echo '</TR></TABLE>';
echo "<b><br>".
_("*If more than one teacher will be adding comments for this student:</b><br>
<ul>
<li>Type your name above the comments you enter.<br>
</li>
<li>Leave space for other teachers to enter their comments.</li>
</ul>");

?>